package service.Impl;

import dao.mapper.OrderLineMapper;
import org.apache.ibatis.session.SqlSession;
import service.IOrderLineService;
import utils.SqlSessionUtil;
import vo.Order;
import vo.OrderLine;

import java.util.List;

public class IOrderLineServiceImpl implements IOrderLineService {
    SqlSession sqlSession=new SqlSessionUtil().sqlSession;
    OrderLineMapper orderLineMapper=sqlSession.getMapper(OrderLineMapper.class);
    @Override
    public void addOrderLine(int orderId, int bookId, int quanlity) {
        OrderLine orderLine=new OrderLine();
        orderLine.setOrderId(orderId);
        orderLine.setBookId(bookId);
        orderLine.setQuanlity(quanlity);
        orderLineMapper.addOrderLine(orderLine);

        sqlSession.commit();
    }

    @Override
    public OrderLine selectOrderLine(int orderId, int bookId) {
        OrderLine orderLine=orderLineMapper.selectOrderLine(orderId,bookId);
        return orderLine;
    }

    @Override
    public List<OrderLine> selectOrderLineByOrderId(int orderId) {
        return orderLineMapper.selectOrderLineByOrderId(orderId);
    }
}
